<script>
	$(function(){
		var validator = new common.validator({
			formID: "div_regist",
			clientValidate: function(){
			},
			severValidate: {
			}
		}); 
		
		$("#btn_regist").click(function(){
			if(validator.validate() == false){
				validator.showErrors();
			}else{
				validator.clear();
			}	
		});
		$('#user_submit').click(function() {
			var obj= {
				email : $("#user_email").val().trim(),
				password : $("#user_password").val().trim(),
				first_name : $("#user_first_name").val().trim(),
				last_name : $("#user_last_name").val().trim(),
				phone: $("#user_phone").val().trim(),
				gender : $("#user_gender").val() || 0,
				address : $("#user_address").val().trim()
			};
			$.ajax({
			  url: ROOT_URL + '/user/addregist',
			  type: "POST",
			  data: {
				info : JSON.stringify(obj)
			  },
			  dataType : "json",
			  success: function(result) {
				if(result.status == "success"){
					window.location = ROOT_URL;
				}else{
					alert(result.msg);
				}
			  }
			});
			return false;
		});
	});

</script>
<form id="form_regist" class="regist_content">
    <div class="content">
        <div class="modal_top">
            <h1>Đăng Ký - Create Your Account</h1>
        </div>
        <div class="modal_bottom">
            <div class="bud_errors" style="height: 54px"></div>
            <div id="signup_left">
                <div id="signup_table">
                    <div class="half_field">
                        <div>
                            <label for="user_first_name">First Name:</label>
                            <input id="user_first_name" name="user[first_name]" validator="required space" size="30" type="text">
                        </div>
                        <div>
                            <label for="user_last_name">Last Name:</label>
                            <input id="user_last_name" name="user[last_name]" validator="required space" size="30" type="text" >
                        </div>
                    </div>
                    <div class="field">
                        <label for="user_email">Email:</label>
                        <input id="user_email" name="user[email]" validator="required space email" size="30" type="text">
                    </div>
                    <div class="half_field">
                        <div>
                            <label for="user_password">Mật khẩu:</label>
                            <input id="user_password" name="user[password]" validator="required space" size="30" type="password">
                        </div>
                        <div>
                            <label for="user_password_confirmation">Nhắc lại mật khẩu:</label>
                            <input id="user_password_confirmation" name="user[password_confirmation]" validator="required space" size="30" type="password">     
                        </div>
                    </div>
                    <div class="half_field">        
                        <div>
                            <label for="user_phone">Điện Thoại:</label>
                            <input id="user_phone" name="user[phone]" validator="required space number" size="30" type="text">
                        </div>        
                        <div>
                            <label for="user_gender">Giới Tính:</label>
                            <select id="user_gender" name="user[gender]"><option value=""></option>
                                <option value="0">Nam</option>
                                <option value="1">Nữ</option></select>
                        </div>
                    </div>
                    <div class="field">
                        <label for="user_address">Địa chỉ:</label>
                        <input id="user_address" name="user[address]" size="30" type="text">
                    </div>
                    <div class="field">
                    <input class="button_action" data-disable-with="Please Wait..." id="user_submit" name="commit" value="Create Account" type="submit">
                    </div>
                </div>
            </div>
            <div id="signup_right">
                <h3>Why Shop Alice?</h3>
                <ul>
                    <li><span class="icon-truck"></span>Free Shipping</li>
                    <li><span class="icon-pricetag"></span>Automatic Coupons</li>
                    <li><span class="icon-auto"></span>Auto-Delivery Available</li>
                    <li><span class="icon-warm_fuzzy"></span>Warm Fuzzies Inside</li>
                </ul>
            </div>

<div id="signup_bottom">
  Already have an Alice account? <a href="/login" data-remote="true">Login.</a>
</div>


    </div>
	
    </div>
</form>
